package com.hut.oa.model.dao.discuss;


import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.hut.oa.model.bean.DiscussArea;
import com.hut.oa.model.bean.DiscussComment;

public interface DiscussCommentDao extends PagingAndSortingRepository<DiscussComment, Long>{
	//根据帖子查找评论
	@Query("from DiscussComment dc where dc.discuss=:discuss")
	Page<DiscussComment> discussList(@Param("discuss") DiscussArea discuss,Pageable pageable);
	
	//点赞加一
	@Modifying
	@Query("UPDATE DiscussComment dt SET dt.thumbNum=dt.thumbNum+1 WHERE dt.id=:id")
	int updatethumbNum(@Param("id")Long id);
	//回复加一
	@Modifying
	@Query("UPDATE DiscussComment dt SET dt.replyNum=dt.replyNum+1 WHERE dt.id=:id")
	int updatereplyNum(@Param("id")Long id);
	
	
}
